package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
	"stargazer/xnat/xnetc/client"
)

func readConfig(configPath string, config *client.Config) error {
	bytes, err := ioutil.ReadFile(configPath)
	if err != nil {
		fmt.Println("ReadFile: ", err.Error())
		return err
	}
	err = json.Unmarshal(bytes, &config)
	if err != nil {
		fmt.Println("json unserilize failed: ", err.Error())
		return err
	}
	return nil
}

func main() {
	conf := client.Config{}
	err := readConfig("./config.json", &conf)
	fmt.Println(conf.Username)
	client.RunClient(conf)

	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
